<template>
  <div class="hospitalInfoCss">
    <div class="titleCss">XXXXX医院</div>
    <div class="smallTitleCss">
      <span>综合医院</span>
    </div>
    <div class="bodyCss">
      <div class="customTableCss" style="padding-bottom: 25px;border-bottom: 1px solid #f2f2f2;">
        <table border="1">
          <tbody>
            <tr>
              <td class="tableLabelCss">医师名称</td>
              <td>张三</td>
              <td class="tableLabelCss">医师执业编号</td>
              <td>95465191561</td>
            </tr>
            <tr>
              <td class="tableLabelCss">医师执业范围</td>
              <td>临床</td>
              <td class="tableLabelCss">执业范围</td>
              <td>内科专业、外科专业</td>
            </tr>
            <tr>
              <td class="tableLabelCss">处方权限授权</td>
              <td>抗菌药品、麻醉药品</td>
              <td class="tableLabelCss">异常内容</td>
              <td>使用非执业范围内药物</td>
            </tr>
          </tbody>
        </table>
      </div>
      <div class="bodyTitleCss">开药记录</div>
      <div class="tableCss">
        <el-table
          max-height="380"
          :data="tableData"
          border
          style="width: 100%">
          <el-table-column
            prop="data1"
            label="药品名称"
            min-width="250">
            <template #default="scope">
              <span :style=" scope.row.data3 === 0 ? 'color:red;':''">{{ scope.row.data1 }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="data2"
            label="药物类型"
            min-width="100">
            <template #default="scope">
              <span :style=" scope.row.data3 === 0 ? 'color:red;':''">{{ data2Map[scope.row.data2] }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="data2"
            label="是否异常"
            min-width="100">
            <template #default="scope">
              <span :style=" scope.row.data3 === 0 ? 'color:red;':''">{{ data3Map[scope.row.data3] }}</span>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <div class="bottomBtnCss">
      <el-button @click="goBackBtn">返回</el-button>
    </div>
  </div>
</template>

<script>
export default {
  data(){
    return{
      tableData:[],
      data3Map:{
        0:'是',
        1:'否',
      },
      data2Map:{
        0:'‌感冒类药品',
        1:'‌咳喘类药品',
        2:'精神类药品',
      }
    }
  },
  mounted(){
    this.getList()
  },
  methods:{
    getList(){
      const random = Math.floor( Math.random() * 30 ) + 5
      let list = []
      for( let i=0;i< random;i++){
        const random1 = Math.floor( Math.random() * 3 )
        const random2 = Math.floor( Math.random() * 2 )
        list.push({
          data1:'【测试数据】xxxxxxxxx药品',
          data2:random1,
          data3:random2
        })
      }
      this.tableData = list
    },
    goBackBtn(){
      this.$router.back()
    },
  },
}
</script>

<style lang="scss" scoped>
.hospitalInfoCss{
  overflow: hidden;
  position: relative;
  background-color: #fff;
  padding: 20px;
  border-radius: 10px;
  height: calc( 100vh - 66px - 40px);
  display: flex;
  flex-direction: column;
  .titleCss{
    text-align: center;
    font-size: 24px;
    font-weight: bold;
  }
  .smallTitleCss{
    font-size: 18px;
    margin-top: 10px;
    text-align: center;
  }
  .bodyCss{
    margin-top: 20px;
    margin-left: 20px;
    width: calc( 100% - 10px);
    padding-right: 40px;
    overflow-y: auto;
    height: calc( 100% - 140px);
    padding-bottom: 20px;
    .customTableCss{
      table {
        border-collapse: collapse;
        width: 100%;
        line-height: 34px;
        &:not(:first-child){
          margin-top: 15px;
        }
        .tableLabelCss{
          font-weight: bold;
        }
        .tableValueCss{
          color: green;
          width: 200px;
          text-align: center;
          font-weight: bold;
        }
      }
      th, td {
        border: 1px solid black;
        padding: 8px;
        text-align: left;
      }
      th {
        background-color: #f2f2f2;
      }
      tr:last-child td {
        border-bottom: none;
      }
      td:nth-child(2) {
        border-right: none;
      }
    }
    .bodyTitleCss{
      text-align: left;
      font-size: 20px;
      font-weight: bold;
      margin-top: 20px;
    }
    .tableCss{
      margin-top: 10px;
    }
  }
  .bottomBtnCss{
    margin-top: auto;
    text-align: right;
  }
}
</style>